class Solution(object):
    def maxProduct(self, s):
        s = list(s)
        n = len(s)
        p = [0] * n
        p[0] = 0
        max_r = 0
        center = 0
        ans = 0
        for j in range(1, n):
            if j > max_r:
                r = 1
                while j + r < n and j - r >= 0 and s[j + r] == s[j - r]:
                    r += 1
                r -= 1
                max_r = j + r
                center = j
            else:
                marrior_i = 2 * center - j
                r = min(p[marrior_i], max_r - j) + 1
                while j + r < n and j - r >= 0 and s[j + r] == s[j - r]:
                    r += 1
                r -= 1
                if r > max_r - j:
                    max_r = j + r
                    center = j
            p[j] = r
        st_end = [1] * n
        index0 = 1
        index1 = 1
        while index0 < n:
            while index1 <= p[index0] + index0:
                st_end[index1] = max(st_end[index1 - 1], 2 * (index1 - index0) + 1)
                index1 += 1
            index0 += 1
        st_start = [1] * n
        index0 = n - 2
        index1 = n - 2
        while index0 >= 0:
            while index1 >= index0 - p[index0]:
                st_start[index1] = max(st_start[index1 + 1], 2 * (index0 - index1) + 1)
                index1 -= 1
            index0 -= 1
        for i in range(n - 1):
            ans = max(ans, st_end[i] * st_start[i + 1])
        return ans





data = Solution()
s = "a" * 100000
print(data.maxProduct(s))
# s = "zaaaxbbby"
# print(data.maxProduct(s))